package com.yuxi.shuzu;

import java.util.Arrays;
import java.util.Scanner;

public class Demo8 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int[] arr = new int[10];
        int[] arr2 = new int[arr.length];
        for (int i = 0; i < arr.length; i++) {
            System.out.println("请输入第"+(i+1)+"个数");
            arr[i] = input.nextInt();
        }
        int[] newarr = getArr2(arr, arr2);
        getPrint(arr,newarr);

    }

    public static void getPrint(int[] arr, int[] newarr) {
        System.out.println("原数组:"+Arrays.toString(arr));
        System.out.println("处理后的数组:"+Arrays.toString(newarr));
    }

    public static int[] getArr2(int[] arr, int[] arr2) {
        int j = 0;
        int y = arr2.length-1;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i]%2!=0){
                arr2[j] = arr[i];
                j++;
            }else {
                arr2[y] = arr[i];
                y--;
            }
        }
        return arr2;
    }
}
